'''
#继承的基本语法
class F:
    c = "绿色"
    def h(s,c):
        print("水果是：",c,"的！")
        print("水果已经收获了。。。。")
        print("水果原来是：",F.c,"的！")
class A(F):
    c = "红色"
    def __init__(s):
        print("我是苹果")

class O(F):
    c = "橙色"
    def __init__(s):
        print("我是橘子")

class B(F):
    c = "黄色"
    def __init__(s):
        print("我是香蕉")

a = A()
a.h(a.c)
o = O()
o.h(o.c)
b = B()
b.h(b.c)



#方法重写




class F:
    c = "绿色"
    def h(s,c):
        print("水果是：",c,"的！")
        print("水果已经收获了。。。。")
        print("水果原来是：",F.c,"的！")
class A(F):
    c = "红色"
    def __init__(s):
        print("我是苹果")
    def h(s,c):
        print("苹果是：",c,"的！")
        print("苹果已经收获了。。。。")
        print("苹果原来是：",F.c,"的！")
class O(F):
    c = "橙色"
    def __init__(s):
        print("我是橘子")
    def h(s,c):
        print("橘子是：",c,"的！")
        print("橘子已经收获了。。。。")
        print("橘子原来是：",F.c,"的！")
class B(F):
    c = "黄色"
    def __init__(s):
        print("我是香蕉")
    def h(s,c):
        print("香蕉是：",c,"的！")
        print("香蕉已经收获了。。。。")
        print("香蕉原来是：",F.c,"的！")
a = A()
a.h(a.c)
o = O()
o.h(o.c)
b = B()
b.h(b.c)


'''

#派生类中调用__init__()方法




class F:
    def __init__(s,c = "绿色"):
        F.c = c
    def h(s,c):
        print("水果是：",c,"的！")
        print("水果已经收获了。。。。")
        print("水果原来是：",F.c,"的！")
class A(F):
    c = "红色"
    def __init__(s):
        print("我是苹果")
        super().__init__()   #调用基类构造方法
    def h(s,c):
        print("苹果是：",c,"的！")
        print("苹果已经收获了。。。。")
        print("苹果原来是：",F.c,"的！")
class O(F):
    c = "橙色"
    def __init__(s):
        print("我是橘子")
        super().__init__()   #调用基类构造方法
    def h(s,c):
        print("橘子是：",c,"的！")
        print("橘子已经收获了。。。。")
        print("橘子原来是：",F.c,"的！")
class B(F):
    c = "黄色"
    def __init__(s):
        print("我是香蕉")
        super().__init__()   #调用基类构造方法
    def h(s,c):
        print("香蕉是：",c,"的！")
        print("香蕉已经收获了。。。。")
        print("香蕉原来是：",F.c,"的！")
a = A()
a.h(a.c)
o = O()
o.h(o.c)
b = B()
b.h(b.c)
